library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.5
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.8
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.0.5
## Warning: package 'tibble' was built under R version 4.0.5
## Warning: package 'tidyr' was built under R version 4.0.5
## Warning: package 'readr' was built under R version 4.0.5
## Warning: package 'dplyr' was built under R version 4.0.5
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(dplyr)
library(lubridate)
## Warning: package 'lubridate' was built under R version 4.0.5
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(plotly)
## Warning: package 'plotly' was built under R version 4.0.5
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(ggplot2)
library(here)
## Warning: package 'here' was built under R version 4.0.5
## here() starts at C:/Users/sears/Documents/Repos/bighorn
Loading in the data
# read in met data
met <- read_csv(here('bighorn_met_composite.csv')) %>%
mutate(dt_use = parse_date_time(datetime,
orders = c('%m/%d/%Y %H:%M',
'%Y-%m-%d %H:%M'))) %>%
select(-datetime)
## Rows: 49630 Columns: 19
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): datetime
## dbl (18): SnowD_m, Rn_Wm2, u_ms, VWC_5, VWC_20, VWC_50, Ts_5, Ts_20, Ts_50, ...
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
# read in tipping bucket data
rain <- read_csv(here('bighorn_rain_composite_new.csv')) %>%
mutate(dt_use = parse_date_time(datetime,
orders = c('%m/%d/%Y %H:%M',
'%Y-%m-%d %H:%M'))) %>%
select(-datetime)
## Rows: 108597 Columns: 2
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): datetime
## dbl (1): tips
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
# read in stage data
stage <- read_csv(here('bighorn_stage_composite_new.csv')) %>%
mutate(dt_use = parse_date_time(DateTime,
orders = c('%m/%d/%Y %H:%M',
'%m/%d/%y %I:%M:%S %p'))) %>%
select(-c(DateTime, T_C)) %>%
rename(Pw_kPa = P_kPa)
## Rows: 201631 Columns: 3
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): DateTime
## dbl (2): P_kPa, T_C
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
# read in baro data
baro <- read_csv(here('bighorn_baro_composite_new.csv')) %>%
mutate(dt_use = parse_date_time(DateTime,
orders = c('%m/%d/%Y %H:%M',
'%m/%d/%y %I:%M:%S %p'))) %>%
select(-c(DateTime, T_C)) %>%
rename(Pa_kPa = P_kPa)
## Rows: 203211 Columns: 3
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): DateTime
## dbl (2): P_kPa, T_C
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
#join stage and baro DFs to get stage height
stage <- left_join(stage, baro, by="dt_use")
# get stage in kPa, convert to stage in cm
stage <- stage %>%
mutate(stage_kPa = Pw_kPa -Pa_kPa,
stage_cm = stage_kPa * 10.197162129779)
Plotting a basic time series of each variable
snowdepth <- ggplot(met, aes(x= dt_use, y = SnowD_m)) +
geom_point() +
ggtitle('snow depth (m)')
ggplotly(snowdepth)
netrad_old <- ggplot(met, aes(x= dt_use, y = Rn_Wm2)) +
geom_point() +
ggtitle('net rad_old (Wm2)')
ggplotly(netrad_old)
windspeed <- ggplot(met, aes(x= dt_use, y = u_ms)) +
geom_point() +
ggtitle('wind speed (m/s)')
ggplotly(windspeed)
sm <- ggplot(met, aes(x=dt_use)) +
geom_line(aes(y=VWC_5, color='5cm')) +
geom_line(aes(y=VWC_20, color='20cm')) +
geom_line(aes(y=VWC_50, color='50cm')) +
ggtitle('soil moisture (%)')
ggplotly(sm)